﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Runtime.CompilerServices;

namespace ForumLibrary.Data
{
    public sealed class ForumData
    {
        private static List<ForumUser> _users = new List<ForumUser>();
        private static List<Hashtable> _refreshFlags = new List<Hashtable>(3);
        private static Hashtable _notifyFlags = new Hashtable();
        private static Logger log = new Logger("server", "Server");

        private static ForumData forumData = null;

        private ForumData()
        {
        }

        [MethodImpl(MethodImplOptions.Synchronized)]
        public static ForumData getInstance()
        {
            if (forumData == null)
            {
                forumData = new ForumData();
                initFlagsHT();
            }
            return forumData;
        }
        
        public List<ForumUser> Users { get { return _users; } }
        public List<Hashtable> RefreshFlags { get { return _refreshFlags; } }
        public Hashtable NotifyFlags { get { return _notifyFlags; } }
        public Logger logger { get { return log; } }

        private static void initFlagsHT()
        {
            _refreshFlags.Add(new Hashtable());
            _refreshFlags.Add(new Hashtable());
            _refreshFlags.Add(new Hashtable());
        }

      /*  private void initUserFlags(string username, bool val)
        {
            try
            {
                _refreshFlags[0].Add(username, val);
                _refreshFlags[1].Add(username, val);
                _refreshFlags[2].Add(username, val);
                _notifyFlags.Add(username, val);
            }
            catch
            {
            }
        }*/

       /* private void setUserFlag(string username, int type)
        {
            _refreshFlags[type].Add(username, true);
        }

        private void setUserNotify(string username)
        {
            _notifyFlags.Add(username, true);
        }*/

    }
}
